/*
let passCode = 'secret1 correct';

class Employee {
    private _fullName: string

    // tsc demo.ts --target es5
    get FullName(): string {
        return this._fullName
    }

    set FullName(newName: string) {
        if (passCode && passCode === 'secret correct') {
            this._fullName = newName
        } else {
            console.log('Error:报错!')

        }
    }

}

let employee = new Employee();
employee.FullName = 'fork';
if (employee.FullName) {
    console.log(employee.FullName)
}*/

/*

function ajax(url: any = '/user/list', method: string = 'GET') {
    console.log(url, method)
}

//如果想要默认值，可以给url赋值为undefined
let res = ajax(undefined,'post');
*/
/*



//泛型约束
interface LengthWise {
    length: number
}

//用LengthWise约束范型，
function logger<T extends LengthWise>(val: T) {
    console.log(val.length)
}

// logger<string>('d');
logger({length: 2});
*/

/*
class Animal {
    length: string
}

class Bee extends Animal {
    bee: string = 'bee1'

    getBee(): string {
        console.log(this.bee)
        return this.bee
    }

}

class Lion extends Animal {
    lion: string = 'lion1'

    getLione(): string {
        console.log(this.lion)
        return this.lion
    }


}

function createZoo(animal:Animal[]): Animal[] {
    // console.log('animal',animal)
    console.log(animal[0]., animal[1])
    return []

}
let bee = new Bee();
let lion = new Lion();
let animal = [bee,lion]
createZoo(animal);*/


class Animal {
    name!: string;
}

class Bird extends Animal {
    swing: number = 6
}

//其实就是检测他是不是某个构造函数的实例：object instanceof constructor   object(某个实例对象)   constructor(某个构造函数)
function getName(animal: Animal) {
    if (animal instanceof Bird) {
        console.log(animal.swing);
    } else {
        console.log(animal.name);
    }
}

let bird = new Bird();
getName(bird)












